<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, INItial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Hello</title>
</head>
<body>
</body>
<script>
    //获取url参数
    function getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) {
                return pair[1];
            }
        }
        return (false);
    }
    // 获取access_token
    const token = getQueryVariable("access_token");
    // 调用用户信息接口
    fetch('https://api.github.com/user', {
        headers: {
            Authorization: 'token ' + token
        }
    })
    // 解析请求的JSON
     .then(res => res.json())
     .then(res => {
        // 返回用户信息
        const nameNode = document.createTextNode(`Hi, ${res.name}, Welcome to login our site by GitHub!`)
        document.body.appendChild(nameNode)
     })
</script>
</html>